/*
 * GoodsDetailActivity.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.goodsdetail;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.yidiandao.business.R;
import com.yidiandao.business.base.BaseActivity;
import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.utils.ActivityUtils;

/** 商品详情页面. */
public class GoodsDetailActivity extends BaseActivity {

    private GoodsDetailFragment mGoodsDetailFragment;

    public static void actionStart(Activity activity, String goodsId) {
        Intent intent = new Intent(activity, GoodsDetailActivity.class);
        intent.putExtra(Intents.HOME_GOODS_ID, goodsId);
        activity.startActivity(intent);
    }

    public static void actionStart(Context context, String goodsId) {
        Intent intent = new Intent(context, GoodsDetailActivity.class);
        intent.putExtra(Intents.HOME_GOODS_ID, goodsId);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }

    @Override
    protected void initFragment() {
        mGoodsDetailFragment =
                (GoodsDetailFragment)
                        getSupportFragmentManager().findFragmentById(R.id.container_goods_detail);
        if (mGoodsDetailFragment == null) {
            mGoodsDetailFragment = GoodsDetailFragment.getInstance(getIntent().getExtras());
            ActivityUtils.addFragmentToActivity(
                    getSupportFragmentManager(), mGoodsDetailFragment, R.id.container_goods_detail);
        }
    }

    @Override
    protected void initPresenter() {
        new GoodsDetailPresenter(mGoodsDetailFragment);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_goods_detail;
    }
}
